<?php
  require("../global.php");
  
if($_REQUEST['formsub']=='submenu'){
    $op_time=date("Y-m-d");
	$_REQUEST['customer_id'] = mb_convert_encoding($_REQUEST['customer_id'], "GBK", "UTF-8");//"UTF-8", "GBK"
	$_REQUEST['customer'] = mb_convert_encoding($_REQUEST['customer'], "GBK", "UTF-8");
	$_REQUEST['province'] = mb_convert_encoding($_REQUEST['province'], "GBK", "UTF-8");
	$_REQUEST['city'] = mb_convert_encoding($_REQUEST['city'], "GBK", "UTF-8");
	$_REQUEST['area'] = mb_convert_encoding($_REQUEST['area'], "GBK", "UTF-8");
	$_REQUEST['address'] = mb_convert_encoding($_REQUEST['address'], "GBK", "UTF-8");
	$_REQUEST['road'] = mb_convert_encoding($_REQUEST['road'], "GBK", "UTF-8");
	$_REQUEST['bank_name'] = mb_convert_encoding($_REQUEST['bank_name'], "GBK", "UTF-8");
	$_REQUEST['a_name'] = mb_convert_encoding($_REQUEST['a_name'], "GBK", "UTF-8");
	$_REQUEST['a_sex'] = mb_convert_encoding($_REQUEST['a_sex'], "GBK", "UTF-8");
	$_REQUEST['a_tell'] = mb_convert_encoding($_REQUEST['a_tell'], "GBK", "UTF-8");
	$_REQUEST['a_fax'] = mb_convert_encoding($_REQUEST['a_fax'], "GBK", "UTF-8");
	$_REQUEST['a_phone'] = mb_convert_encoding($_REQUEST['a_phone'], "GBK", "UTF-8");
	$_REQUEST['a_ywy'] = mb_convert_encoding($_REQUEST['a_ywy'], "GBK", "UTF-8");
	
	
	if(!isset($_REQUEST['customer_id']) || !empty($_REQUEST['customer_id']))
	{
	       $db->fn_insert('dcusperson','per_id,customer_id,name,sex,tell,fax,phone,ywy_no',
			        "'','".$_REQUEST['customer_id']."','".$_REQUEST['a_name']."','".$_REQUEST['a_sex']."',
			        '".$_REQUEST['a_tell']."','".$_REQUEST['a_fax']."','".$_REQUEST['a_phone']."','".$_REQUEST['a_ywy']."'"); 
					
		  $per_id = $db->insert_id();
	}else{
    $db->fn_insert('dcustomermsg','customer_id,customer,province,city,area,address,road,bank_name,opr_no,opr_time,cus_group',
    "'','".$_REQUEST['customer']."','".$_REQUEST['province']."','".$_REQUEST['city']."','".$_REQUEST['area']."','".$_REQUEST['address']."',
    '".$_REQUEST['road']."','".$_REQUEST['bank_name']."','$session_loginno','$op_time','1'");
    $customer_id=$db->insert_id();
    

    $db->fn_insert('dcusperson','per_id,customer_id,name,sex,tell,fax,phone,ywy_no',
			        "'','".$customer_id."','".$_REQUEST['a_name']."','".$_REQUEST['a_sex']."',
			        '".$_REQUEST['a_tell']."','".$_REQUEST['a_fax']."','".$_REQUEST['a_phone']."','".$_REQUEST['a_ywy']."'"); 

    $per_id = $db->insert_id();				
        		 
          
 }
 
 	$_REQUEST['customer_id'] = mb_convert_encoding($_REQUEST['customer_id'], "UTF-8", "GBK");//"UTF-8", "GBK"
	$_REQUEST['customer'] = mb_convert_encoding($_REQUEST['customer'], "UTF-8", "GBK");
	$_REQUEST['a_name'] = mb_convert_encoding($_REQUEST['a_name'], "UTF-8", "GBK");
	$_REQUEST['a_tell'] = mb_convert_encoding($_REQUEST['a_tell'], "UTF-8", "GBK");
	$_REQUEST['a_fax'] = mb_convert_encoding($_REQUEST['a_fax'], "UTF-8", "GBK");
	$_REQUEST['a_phone'] = mb_convert_encoding($_REQUEST['a_phone'], "UTF-8", "GBK");
	$_REQUEST['a_ywy'] = mb_convert_encoding($_REQUEST['a_ywy'], "UTF-8", "GBK");
	
 
   if($per_id !=''){
       //echo '1';
echo '1'.'#'.$_REQUEST['customer'].'#'.$_REQUEST['a_name'].'#'.$_REQUEST['dept'].'#'.$_REQUEST['cus_group'].'#'.$_REQUEST['a_tell'].'#'.$_REQUEST['a_fax'].'#'.$_REQUEST['a_phone'].'#'.$_REQUEST['a_ywy'].'#'.'1';	   
   }else{
       //echo '0';
	   echo '1'.'#'.$_REQUEST['customer'].'#'.$_REQUEST['a_name'].'#'.$_REQUEST['dept'].'#'.$_REQUEST['cus_group'].'#'.$_REQUEST['a_tell'].'#'.$_REQUEST['a_fax'].'#'.$_REQUEST['a_phone'].'#'.$_REQUEST['a_ywy'].'#'.'1';
   }
} 

        

?>
